In the previous exercise, we already have created our first loop using an if-else statement. Here we want to deepen our understanding of loops and apply some more of them.
for() loop for this purpose.
for() loops are nice, but there are alternatives, right?
lapply() function to iterate through the list - do you see any differences to the for() call?
To conclude this exercise, let’s turn to code styling. For this purpose, look at this code fragment here:
mean(sqrt(as.numeric(data.frame(id = 1, age = "20")$age)))
Using the commands in such a way makes the code somewhat challenging to read and understand. You should have learned that pipes provide a straightforward approach to address this issue.
.$col_name here.